package com.nangle.managehost.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.nangle.managehost.R;
import com.nangle.managehost.entity.Room;

import java.util.List;

/**
 * 作者：Administrator on 2016/9/23 14:48
 * 描述：
 */
public class DeviceWardAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private Context mContext;
    private List<Room> mDatas;

    public DeviceWardAdapter(Context context, List<Room> mDatas) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.mDatas = mDatas;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.device_wardgriditem, parent,
                    false);
            viewHolder = new ViewHolder();
            viewHolder.textView = (TextView)convertView.findViewById(R.id.room_number);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.textView.setText(mDatas.get(position).getRoomnumber()+"");
        if(position==5){
            viewHolder.textView.setBackgroundResource(R.drawable.abward_icon);
        }else{
            viewHolder.textView.setBackgroundResource(R.drawable.ward_icon);
        }
        return convertView;
    }

    private final class ViewHolder {
        TextView textView;
    }

}
